from flask import jsonify
from flask_jwt import current_identity
from functools import wraps

#admin 角色才可以往下继续
def permission_auth(role):
    def wrappers(func):
        @wraps(func)
        def decorator(*args, **kwargs):
            if not current_identity.role in role:
                return jsonify(dict(message=dict(status=401, code=401, message="Permission Denied")))
            return func(*args, **kwargs)
        return decorator
    return wrappers
